<?php
// 帖子管理
// 查询用户数据,默认是禁言的用户和冻结的账户
$page = @$_GET['page'];
if ($page < 0) {
    $page = 0;
}
$count = @$_GET['count'];
if ($count < 1) {
    $count = 10;
}

// 回收站恢复删除的帖子
$datas = array();
$sql = "SELECT pid,modid,uid,title,isDel,create_time,(select alias from `userinfo_tb` as u where u.uid=p.uid) as alias,(select title from `zone_modul_tb` as z where z.zid=p.modid) as modul FROM post_tb as p WHERE isDel=1 ORDER BY create_time DESC LIMIT ".($page*$count).",{$count}";
my_mysql_query($sql, $datas);

// 获取删除帖子的所有总数
$sum = array();
$sql = "SELECT count(pid) as sum FROM post_tb WHERE isDel=1 ";
my_mysql_query($sql, $sum);
$sum = $sum[0]['sum'];
?>


<style type="text/css">
#table{
    text-align: center;
}
#table1{
    padding-left: 250px;
    text-align: center;
    border-bottom: 1px solid rgb(210,210,210);
}
#table1 input {
    width: 200px;
    height: 20px;
    outline: none;
}
#table td,#table th,
#table1 td,#table1 th{
    padding: 0 15px;
}

#table tr:nth-child(even){
    border-bottom: 1px dotted rgb(210,210,210);
}
.red a:link{
    color: red;
    text-decoration:none;
}
.green a:link{
    color: green;
    text-decoration:none;
}
a:visited{
    text-decoration:none;
}
a:active{
    text-decoration:underline;
}
a:hover {
    text-decoration:underline;
}
td button {
    width: 79px;
    height: 32px;
    color: white;
    font-size: 14px;
    border: none;
    outline: none;
    cursor: pointer;
    background: url(image/agree.png) 0 0 no-repeat;
}
</style>

<table id="table" cellspacing="0">
    <caption><h1>删除的帖子列表</h1></caption>
    <tr>
        <th>序号</th>
        <th>帖子名称</th>
        <th>所属版块</th>
        <th>创建时间</th>
        <th>楼主</th>
        <th>操作</th>
    </tr>

    <?php
    // 获取删除的帖子
    if ($sum > 0){
        $i=1;
        foreach($datas as $post){
            $pid = $post['pid'];
            echo '<tr>';
            echo '<td>'.$i++.'</td>';
            echo '<td>'.$post['title'].'</td>';
            echo '<td>'.$post['modul'].'</td>';
            echo '<td>'.date('Y-m-d',$post['create_time']).'</td>';
            echo '<td>'.$post['alias'].'</td>';
            echo "<td><a href=\"post_handler.php?action={$action}&pid={$pid}&behavior=recycled\">恢复帖子</td>";
            echo '</tr>';
        }
    }
    ?>
</table>

<div class="toolbar">
    <form action="index.php" method="GET">
        <input type="hidden" name="action" value="<?php echo $action; ?>">
        共有<?php echo ceil($sum/$count);?>页,每页有
        <input type="text" size="3" name="count" value="<?php echo $count; ?>">条信息
        当前第<?php echo ($page+1);?>页,跳到第
        <input type="text" size="3" name="page" value="<?php echo $page+2; ?>">页
        <input type="submit" value="GO">
    </form>
</div>
